<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script>
window.onload = function()
{
		var oBtn1 = document.getElementById('btn1');
		var oBtn2 = document.getElementById('btn2');
	 var timer = null;
	
	oBtn1.onclick= ()=>{timer = setInterval(()=>{ alert(9);},2000);};
	oBtn2.onclick = ()=>{	clearInterval(timer);	};
	
	
	
};
</script>
</head>

<body>
<input type="button" id="btn1">
<input type="button" id="btn2">
</body>
</html>
